#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <iostream>

#include "position.h"

namespace Group5 {

Position::Position(int px, int py){
	x = px;
	y = py;	
}

Position::~Position() {}

Position Position::adjacent_pos( int direction ) const {
	Position p(x, y);
	if ( direction == NORTH ) p.y += GRID_SIZE;
	else if ( direction == SOUTH ) p.y -= GRID_SIZE;
	else if ( direction == EAST ) p.x += GRID_SIZE;
	else p.x -= GRID_SIZE;
	return p;
}

const bool Position::operator==( Position const & p ) const {
	return ( x == p.x && y == p.y );	
}

const bool Position::operator<( Position const & p ) const {
	std::stringstream s1;
	s1 << x;
	s1 << y;
	std::stringstream s2;
	s2 << p.x;
	s2 << p.y;		
	return ( s1.str() < s2.str() );
}

};
